<template>
  <svg :class="svgClass" :style="{...styles, 'opacity': props.opacity, 'color': props.color}" aria-hidden="true">
    <use :xlink:href="iconName" />
  </svg>
</template>

<script setup>
import { defineProps, computed } from 'vue'
const props = defineProps({
  iconClass: {
    type: String,
    required: true
  },
  className: {
    type: String
  },
  size: {
    type: Number,
    default: null
  },
  opacity: {
    type: Number,
    default: null
  },
  color: {
    type: String,
    default: null
  }
})

const iconName = computed(() => `#icon-${props.iconClass}`)
const svgClass = computed(() => {
  if (props.className) {
    return 'svg-icon ' + props.className
  } else {
    return 'svg-icon'
  }
})
const styles = computed(() => {
  const size = props.size
  return size ? { width: `${size}px`, height: `${size}px` } : {}
})
</script>

<style scoped>
.svg-icon {
  fill: currentColor;
  color: #222;
  overflow: hidden;
}
.icon_svg {
  width: 16px;
  height: 16px;
}
</style>
